<template>
	<view class="control-examine">
		<titleName :name="name" :backShow="true"></titleName>
		<view class="manage-wrap">
			<view class="search-wrap">
				<view class="ipt-wrap">
					<input type="text" v-model="params.enterprisename" placeholder="搜索公司名称"
						placeholder-class="ipt-style" />
					<button @click="getList">搜索</button>
				</view>
				<uni-datetime-picker @maskClick="closePicker" v-model="single" type="daterange" @change="dateChange">
					<image class="date-icon" :src="resourceUrl+'msg-date.png'" mode=""></image>
				</uni-datetime-picker>
			</view>
			<view class="single-choice-one" v-if="examineFlag==1">
				<uni-data-select v-model="params.shstatus" :localdata="allWarning"
					@change="changeWarning"></uni-data-select>
				<uni-data-select v-model="params.colorlevel" :localdata="warningLevel"
					@change="changeStatus"></uni-data-select>
				<uni-data-select v-model="params.shresult" :localdata="allStatus"
					@change="changeStatus"></uni-data-select>
			</view>
			<view class="single-choice" v-else>
				<uni-data-select v-model="params.shstatus" :localdata="allWarning"
					@change="changeWarning"></uni-data-select>
				<uni-data-select v-model="params.shresult" :localdata="allStatus"
					@change="changeStatus"></uni-data-select>
			</view>
			<noData v-if="dataList.length==0 && !flagData" />
			<view class="list">
				<view class="item" @click="jumpDetail(item)" v-for="item,index in dataList" :key="index">
					<view class="enterprise">
						<view class="name">{{item.customername}}</view>
						<view v-if="item.shtime" :class="item.shresult==1?'status':'no-down'">
							{{item.shresult==1?'已通过':'已驳回'}}
						</view>
					</view>
					<view class="type-one" v-if="examineFlag==1">
						<view class="name">预警等级：</view>
						<view class="val">{{item.colorlevel==1?'红色预警':item.colorlevel==2?'橙色预警':'黄色预警'}}</view>
					</view>
					<view class="type-one" v-else>
						<view class="name">整改内容：</view>
						<view class="val">{{item.content}}</view>
					</view>
					<view class="type-two">
						<view class="name"><text>{{item.shtime?'审批时间：':'提交时间：'}}</text>
							{{item.shtime || item.committime}}
						</view>
						<view class="val" v-if="item.shresult==0">
							<button class="btn">去审批</button>
						</view>
					</view>

				</view>


			</view>
		</view>

	</view>
</template>

<script setup>
	import titleName from '../../components/titleName.vue'
	import noData from '../../components/noDataShow.vue'
	import {
		resourceUrl
	} from '../../request/config'
	import http from '../../request/index.js'
	import {
		reactive,
		ref
	} from 'vue'
	import {
		onShow,
		onLoad
	} from "@dcloudio/uni-app"
	let name = ref("整改执行审批")
	let examineFlag = ref(1)
	let seltop = ref(1)
	let dataList = ref([])
	let title = ref('')
	let single = ref('')
	let flagData = ref(true)
	let usertype = ref('')
	let params = ref({})
	let selType = ref('')
	let warningLevel = ref([{
		value: 1,
		text: "红色预警"
	}, {
		value: 2,
		text: "橙色预警"
	}, {
		value: 3,
		text: "黄色预警"
	}])
	let allWarning = ref([{
		value: 1,
		text: "已审批"
	}, {
		value: 0,
		text: "待审批"
	}])
	let allStatus = ref([{
		value: 1,
		text: "已通过"
	}, {
		value: 2,
		text: "已驳回"
	}, ])
	let closePicker = () => {
		single.value = ''
		params.value.startdate = ''
		params.value.enddate = ''
	}
	let singleChoice = ref(0)
	let changeWarning = () => {
		getList()
	}
	let changeStatus = () => {
		getList()
	}
	let selChange = (id) => {
		singleChoice.value = id
		params.value.noticetype = id
		getList()
	}

	let jumpDetail = (item) => {

		uni.navigateTo({
			url: `/minePageOther/controlexaminedetail/index?examineFlag=${examineFlag.value}&item=${JSON.stringify(item)}`
			// url: `/homePageOther/environmentdetail/index?id=${id}`
		})
	}

	let jumpControlExamineDetail = () => {
		uni.navigateTo({
			url: `/minePageOther/controlexaminedetail/index?examineFlag=${examineFlag.value}`
		})
	}
	onLoad((e) => {

		if (e.id == 1) {
			examineFlag.value = 1
			name.value = '管控执行审批'
			params.value.noticetype = 9
		} else {
			examineFlag.value = 2
			name.value = '整改执行审批'
			params.value.noticetype = 4
		}

	})
	onShow(() => {

		getList()

	})
	let dateChange = (e) => {

		if (e.length != 0) {
			params.value.startdate = e[0]
			params.value.enddate = e[1]
		} else {
			params.value.startdate = ''
			params.value.enddate = ''
		}


	}
	let getList = () => {
		dataList.value = []
		flagData.value = true
		http({
			url: '/greenAdmNotice/getNeedExecShEnterpriseList',
			data: params.value,
		}).then((res) => {
			if (res.code == 0) {
				flagData.value = false
				dataList.value = res.data.list
			} else {
				flagData.value = false
			}
		})
	}
</script>

<style lang="scss" scoped>
	:deep(.ipt-style) {

		font-weight: 400;
		font-size: 25rpx;
		color: #ABABBB;

	}

	:deep(.uni-icons) {
		font-size: 12upx;
	}

	:deep(.single-choice-one .uni-select) {
		width: 212rpx;
		height: 59rpx;
		background: #FFFFFF;
		border-radius: 30rpx;
		border: 1px solid #999999;

		font-family: Source Han Sans CN;
		font-weight: 500;
		font-size: 24rpx;
		color: #4F5153;
	}

	:deep(.single-choice .uni-select) {
		width: 313rpx;
		height: 59rpx;
		background: #FFFFFF;
		border-radius: 30rpx;
		border: 1px solid #999999;

		font-family: Source Han Sans CN;
		font-weight: 500;
		font-size: 24rpx;
		color: #4F5153;
	}


	.control-examine {
		width: 100vw;
		height: 100vh;
		// padding-top: 160rpx;
		overflow: hidden;

		.manage-wrap {
			height: calc(100vh - 160upx);
			width: 100vw;
			background: #F3F5F7;

			.list {
				height: calc(100vh - 160upx - 96upx - 146upx);
				overflow: scroll;
				display: flex;
				flex-direction: column;
				// padding: 0 26upx;
				padding: 0 26upx 60upx 26upx;
				align-items: center;



				.item {
					width: 100%;
					margin-top: 26upx;
					background: #FFFFFF;
					border-radius: 21rpx;

					// padding: 35upx 34upx 30upx 30upx;
					height: 233upx;

					padding: 36upx 34upx 40upx 30upx;

					.enterprise {
						display: flex;
						align-items: center;
						justify-content: space-between;

						.name {

							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 35rpx;
							color: #080A0B;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
						}

						.status {

							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 26rpx;
							color: #0874FA;
							width: 104rpx;
							height: 46rpx;
							background: #0874FA;
							border-radius: 7rpx;
							background-color: rgb(206, 227, 254);
							line-height: 46upx;
							text-align: center;


						}

						.no-down {



							color: #0874FA;
							width: 104rpx;
							height: 46rpx;
							background: #0874FA;
							border-radius: 7rpx;

							line-height: 46upx;
							text-align: center;




							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 26rpx;
							color: #FA0808;
							background-color: rgb(254, 206, 206);
						}
					}


					.type-one {
						margin-top: 24upx;
						display: flex;
						align-items: center;


						.name {

							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 28rpx;
							color: #666666;
							flex-shrink: 0;
						}

						.val {
							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 28rpx;
							color: #333333;
							white-space: nowrap;
							text-overflow: ellipsis;
							overflow: hidden;
						}
					}

					.type-two {
						margin-top: 14upx;
						display: flex;
						align-items: center;
						justify-content: space-between;

						.name {

							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 26rpx;
							color: #080A0B;


							text {

								font-family: Source Han Sans CN;
								font-weight: 400;
								font-size: 26rpx;
								color: #404246;

							}
						}

						.val {
							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 28rpx;
							color: #333333;

							.btn {
								width: 151rpx;
								height: 56rpx;
								background: #0874FA;
								border-radius: 28rpx;

								font-family: Source Han Sans CN;
								font-weight: 400;
								font-size: 26rpx;
								color: #FFFFFF;
								line-height: 56upx;
								text-align: center;

							}
						}
					}

				}
			}



			.single-choice,
			.single-choice-one {
				width: 100vw;
				height: 97upx;
				display: flex;
				flex-wrap: wrap;
				background-color: #fff;
				padding: 0 38upx;
				justify-content: space-between;



				.name:nth-of-type(4),
				.name:nth-of-type(1) {
					margin-left: 0upx;
				}

				.name {
					width: 216rpx;
					height: 69rpx;
					background: #F7F7F7;
					border-radius: 34rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 27rpx;
					color: #27292B;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-left: 25upx;
				}

				.active {
					background-color: #0874FA;
					color: #fff;
				}
			}

			.search-wrap {
				background-color: #fff;
				height: 146upx;
				padding: 35upx 48upx 22upx 20upx;
				display: flex;
				align-items: center;

				.date-icon {
					width: 43upx;
					height: 40upx;
					margin-left: 24upx;
				}

				.ipt-wrap {
					width: 617rpx;
					height: 73rpx;
					background: #F7F7FE;
					border-radius: 36rpx;
					border: 1px solid #E9E9E9;
					display: flex;
					align-items: center;
					padding-left: 30upx;

					input {
						flex: 1;
					}

					button {
						flex-shrink: 0;
						width: 112rpx;
						height: 73rpx;
						background: #0874FA;
						border-radius: 14rpx;
						line-height: 73upx;
						font-weight: 500;
						font-size: 31rpx;
						color: #FFFFFF;

					}
				}
			}
		}


	}
</style>